#!/bin/sh

rc=0
# Check for gcc, flex and bison - needed for DRBD install

for req in perl flex bison gcc
do
	if [ ! -x /usr/bin/$req ]
	then
		echo "The Linuxha.net software expects a '$req' binary"
		echo "to be available with the following path:"
		echo "/usr/bin/$req"
		rc=1
	fi
done

# Now check we have a level of Perl that is supported.

x=`perl -e 'print "1\n" if $] >= 5.006'`;
if [ -z "$x" ]
then
        echo "Perl version 5.6 or greater must be installed!"
        rc=1
fi

# We do not provide expat or XML::Parser anymore - since these
# are fairly standard install components.

perl -mXML::Parser -e '1;' 2>/dev/null
if [ $? -ne 0 ]
then
	echo "The XML::Parser Perl module is not installed. This module"
	echo "is no longer distributed as part of Linuxha.net. Please"
	echo "install the required vendor supplied package or "
	echo "alternatively the latest version from CPAN."
	rc=2
fi

if [ -f /usr/src/cluster/miitoollib/Makefile ]
then
	echo "*****************************************"
	echo "* Running make distclean for miitoollib *"
	echo "*****************************************"
	cd /usr/src/cluster/miitoollib && make distclean
	echo "*******************************************"
	echo "* Completed make distclean for miitoollib *"
	echo "*******************************************"
fi
exit $rc
